home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / a_utils / expanded.lha / expanded / hdr / List.h < prev    next >
C/C++ Source or Header  |  1992-03-19  |  6KB  |  292 lines

  1. //
  2. // Linear-Affine-Projective Geometry Package
  3. //
  4. // List.h
  5. //
  6. // $Header$
  7. //
  8. // William J.R. Longabaugh 
  9. // University of Washington
  10. //
  11. // Implementation of the linear-affine-projective geometry
  12. // package described in William J.R. Longabaugh, "An Expanded
  13. // System for Coordinate-Free Geometric Programming", Master's 
  14. // thesis, University of Washington, 1992.
  15. //
  16. // Copyright (c) 1992, William J.R. Longabaugh
  17. //   Copying, use and development for non-commercial purposes permitted.
  18. //   All rights for commercial use reserved.
  19. //   This software is unsupported and without warranty; it is
  20. //   provided "as is".
  21. //
  22. // ***********************************************************************
  23.  
  24. #ifndef List_h
  25. #define List_h
  26.  
  27. #include <stream.h>
  28. #include "Lap1.h"
  29. #include "Geom.h"
  30.  
  31. // Maximum size for local storage of list elements:
  32.  
  33. #define MAX_LOCAL_LIST 4
  34.  
  35. // ***********************************************************************
  36. //
  37. // Implementation note:  This list implementation would be a prime
  38. // candidate for using templates if it is ported to a C++ compiler that
  39. // supports them!
  40. //
  41. // ***********************************************************************
  42.   
  43. class ScalarList: public Object
  44. {
  45.  
  46.   private:
  47.  
  48.         Scalar *list;
  49.         int     size;
  50.     Scalar  local[MAX_LOCAL_LIST];  // Local storage for small lists
  51.  
  52.   public:
  53.  
  54. // Constructors.  User must exercise caution with the shortcut
  55. // constructors, to make sure the type of the arguments matches the
  56. // desired constructor!
  57.  
  58.     ScalarList(void) {size = 0; list = (Scalar *)NULL;}
  59.     ScalarList(ScalarList &t);
  60.  
  61.     ScalarList(int n);
  62.     ScalarList(Scalar s, int n);
  63.     ScalarList(Scalar s);
  64.     ScalarList(Scalar s1, Scalar s2);
  65.     ScalarList(Scalar s1, Scalar s2, Scalar s3);
  66.     ScalarList(Scalar s1, Scalar s2, Scalar s3, Scalar s4);
  67.  
  68. // Interrogation / Access:
  69.  
  70.     int Length(void) {return (size);}
  71.     Scalar &operator[](int n);
  72.  
  73. // Concatenation:
  74.  
  75.     ScalarList operator+(ScalarList &l);
  76.     ScalarList operator*(int i);
  77.  
  78. // Assignment:
  79.  
  80.     ScalarList &operator=(ScalarList &t);
  81.  
  82. // Destructor:
  83.  
  84.     ~ScalarList();  
  85.  
  86. // To do debug printing:
  87.  
  88.     void debug_out(ostream &c, int indent);
  89. };
  90.  
  91. // ***********************************************************************
  92.   
  93. class IntList: public Object
  94. {
  95.  
  96.   private:
  97.  
  98.         int *list;
  99.         int  size;
  100.     int  local[MAX_LOCAL_LIST];  // Local storage for small lists
  101.  
  102.   public:
  103.  
  104. // Constructors.  Note how ambiguity prevents some shortcut
  105. // constructors from being defined.
  106. // NOTE: CFRONT 1.2 does not allow an enumerated data type to be used
  107. // to disambiguate constructors.  The compiler treats the enumerated
  108. // type as an integer, which still creates ambiguity!
  109.  
  110.     IntList(void) {size = 0; list = (int *)NULL;}
  111.     IntList(IntList &t);
  112.  
  113.     IntList(int size);
  114.     IntList(int val, int size);
  115.     IntList(int element1, int element2, int element3);
  116.     IntList(int element1, int element2, int element3, int element4);
  117.  
  118. // Interrogation / Access:
  119.  
  120.     int Length(void) {return (size);}
  121.     int &operator[](int n);
  122.  
  123. // Concatenation:
  124.  
  125.     IntList operator+(IntList &l);
  126.     IntList operator*(int i);
  127.  
  128. // Assignment:
  129.  
  130.     IntList &operator=(IntList &t);
  131.  
  132. // Destructor:
  133.  
  134.     ~IntList();  
  135.  
  136. // To do debug printing:
  137.  
  138.     void debug_out(ostream &c, int indent);
  139. };
  140.  
  141.  
  142. // ***********************************************************************
  143. //
  144. // Lists of arbitrary Geometric objects.
  145.   
  146. class GeObList: public Object
  147. {
  148.  
  149.   private:
  150.  
  151.         GeOb  *list;
  152.         int    size;
  153.     GeOb   local[MAX_LOCAL_LIST];  // Local storage for small lists
  154.  
  155.   public:
  156.  
  157. // Constructors
  158.  
  159.     GeObList(void) {size = 0; list = (GeOb *)NULL;}
  160.     GeObList(GeObList &t);
  161.  
  162.     GeObList(int n);
  163.     GeObList(GeOb &g, int n);
  164.     GeObList(GeOb &m);
  165.     GeObList(GeOb &m1, GeOb &m2);
  166.     GeObList(GeOb &m1, GeOb &m2, GeOb &m3);
  167.     GeObList(GeOb &m1, GeOb &m2, GeOb &m3, GeOb &m4);
  168.  
  169. // Interrogation / Access:
  170.  
  171.     int Length(void) {return (size);}
  172.     GeOb &operator[](int n);
  173.  
  174. // Concatenation:
  175.  
  176.     GeObList operator+(GeObList &g);
  177.     GeObList operator*(int s);
  178.  
  179. // Assignment:
  180.  
  181.     GeObList &operator=(GeObList &t);
  182.  
  183. // Destructor:
  184.  
  185.     ~GeObList();  
  186.  
  187. // To do debug printing:
  188.  
  189.     void debug_out(ostream &c, int indent);
  190. };
  191.  
  192. // ***********************************************************************
  193. //
  194. // Lists of spaces:
  195.   
  196. class SpaceList: public Object
  197. {
  198.   private:
  199.  
  200.         Space  *list;
  201.         int    size;
  202.     Space   local[MAX_LOCAL_LIST];  // Local storage for small lists
  203.  
  204.   public:
  205.  
  206. // Constructors
  207.  
  208.     SpaceList(void) {size = 0; list = (Space *)NULL;}
  209.     SpaceList(SpaceList &t);
  210.  
  211.     SpaceList(int n);
  212.     SpaceList(Space &g, int n);
  213.     SpaceList(Space &m);
  214.     SpaceList(Space &m1, Space &m2);
  215.     SpaceList(Space &m1, Space &m2, Space &m3);
  216.     SpaceList(Space &m1, Space &m2, Space &m3, Space &m4);
  217.  
  218. // Interrogation / Access:
  219.  
  220.     int Length(void) {return (size);}
  221.     Space &operator[](int n);
  222.  
  223. // Concatenation:
  224.  
  225.     SpaceList operator+(SpaceList &g);
  226.     SpaceList operator*(int s);
  227.  
  228. // Assignment:
  229.  
  230.     SpaceList &operator=(SpaceList &t);
  231.  
  232. // Destructor:
  233.  
  234.     ~SpaceList();  
  235.  
  236. // To do debug printing:
  237.  
  238.     void debug_out(ostream &c, int indent);
  239. };
  240.  
  241. // ***********************************************************************
  242. //
  243. // Lists of bases:
  244.   
  245. class BasisList: public Object
  246. {
  247.  
  248.   private:
  249.  
  250.         Basis  *list;
  251.         int    size;
  252.     Basis   local[MAX_LOCAL_LIST];  // Local storage for small lists
  253.  
  254.   public:
  255.  
  256. // Constructors
  257.  
  258.     BasisList(void) {size = 0; list = (Basis *)NULL;}
  259.     BasisList(BasisList &t);
  260.  
  261.     BasisList(int n);
  262.     BasisList(Basis &g, int n);
  263.     BasisList(Basis &m);
  264.     BasisList(Basis &m1, Basis &m2);
  265.     BasisList(Basis &m1, Basis &m2, Basis &m3);
  266.     BasisList(Basis &m1, Basis &m2, Basis &m3, Basis &m4);
  267.  
  268. // Interrogation / Access:
  269.  
  270.     int Length(void) {return (size);}
  271.     Basis &operator[](int n);
  272.  
  273. // Concatenation:
  274.  
  275.     BasisList operator+(BasisList &g);
  276.     BasisList operator*(int s);
  277.  
  278. // Assignment:
  279.  
  280.     BasisList &operator=(BasisList &t);
  281.  
  282. // Destructor:
  283.  
  284.     ~BasisList();  
  285.  
  286. // To do debug printing:
  287.  
  288.     void debug_out(ostream &c, int indent);
  289. };
  290.  
  291. #endif
  292.